package com.sservice.web.controller.admin;

import com.sservice.model.vo.ClienteleVo;
import com.sservice.service.service.IClienteleService;
import com.sservice.base.entity.dto.ListResult;
import com.sservice.base.entity.dto.Pagination;
import com.sservice.model.entity.Clientele;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by suweiming on 2017/12/20.
 */

@Controller
@RequestMapping("/admin/clientele")
public class ClienteleAdminController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private IClienteleService dataService;

    @RequestMapping("/query")
    public
    @ResponseBody
    ListResult<Clientele> query(@ModelAttribute ClienteleVo arg) {
        List<Clientele> list = dataService.queryByPage(arg);
        int total = dataService.queryCount(arg);
        Pagination page = new Pagination(arg.getPage(), total, arg.getSize());
        ListResult<Clientele> res = new ListResult(true, list);
        res.setPage(page);
        return res;
    }
}
